package com.example.demo.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo.dto.UserDto;
import com.example.demo.entity.User;
import com.example.demo.entity.Users;
import com.example.demo.mapper.UserMapper;
import com.example.demo.mapper.UsersMapper;
import com.example.demo.service.IUserService;
import com.example.demo.service.IUsersService;
import com.example.demo.vo.UserVo;
import jakarta.annotation.Resource;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors;

@RequiredArgsConstructor
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users> implements IUsersService {

    private UsersMapper usersMapper;

    @Override
    public boolean hasUser(String username) {

//        LambdaQueryWrapper<Users> user = new QueryWrapper<Users>().lambda().eq(Users::getUsername, username);

//        return usersMapper.selectCount(user) > 0;

        return lambdaQuery().eq(Users::getUsername, username).count() > 0;
    }
}
